<?php
require 'include/global.php';

if($_SESSION[usertype]=='recruiter'){
	$sql = "UPDATE pa_recuiter SET `rc_status` = '4' WHERE rc_id = '".$_SESSION[uid]."' ";
	$list = $DB->fetch_one_array("SELECT * FROM pa_recuiter WHERE rc_id='".$_SESSION[uid]."'");
	$username = $list[rc_fname]." ".$list[rc_lname] ;
	$email    = $list[rc_email];
}
if($_SESSION[usertype]=='advisor'){
	$sql = "UPDATE pa_advisory SET `ad_status` = '2' WHERE ad_id = '".$_SESSION[uid]."' ";
	$list = $DB->fetch_one_array("SELECT * FROM pa_advisory WHERE ad_id='".$_SESSION[uid]."'");
	$username = $list[ad_fname]." ".$list[ad_lname] ;
	$email    = $list[ad_email];
}
if($_SESSION[usertype]=='employer'){
	$sql = "UPDATE pa_employer SET `ep_status` = '2' WHERE ep_id = '".$_SESSION[uid]."' ";
	$list = $DB->fetch_one_array("SELECT * FROM pa_employer WHERE ep_id='".$_SESSION[uid]."'");
	$username = $list[ep_fname]." ".$list[ep_lname] ;
	$email    = $list[ep_email];
}
if($_SESSION[usertype]=='candidate'){
	$sql = "UPDATE pa_candidates SET `js_status` = '2' WHERE js_id = '".$_SESSION[uid]."' ";
	$list = $DB->fetch_one_array("SELECT * FROM pa_candidates WHERE js_id='".$_SESSION[uid]."'");
	$username = $list[js_fname]." ".$list[js_lname] ;
	$email    = $list[js_email];
}
$DB->query($sql);

$content = "Please see the following information regarding to the member who just cancled the membership with enetrecruiter.<br><br>
User Name: $username<br>
Email: $email <br>
Candidate Date: ".date('Y-m-d H:i:s',time())."  
";
$to		 = "accounting@enetrecruiter.com,support@enetrecruiter.com,svoline@yahoo.com"; 
$subject = "Membership cancellation notice";

$headers .= 'From: '.trim($username).' <'.trim($email ).'>' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

@mail($to, $subject, $content, $headers);


session_unset();
session_destroy();
echo "<script>alert('Cancel successfully')</script>";
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\">";



?>
